<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <p>obj: {{ obj }}</p>
      <p>arr: {{ arr }}</p>
      <button @click="fn">btn</button>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          obj: {
            a: 3,
          },
          arr: [1, 2],
        },
        methods: {
          fn() {
            this.obj.b = 4;
            // this.obj = { ...this.obj };
            // this.obj = Object.assign({}, this.obj);
            // this.obj = JSON.parse(JSON.stringify(this.obj));
            // this.$forceUpdate();
            // this.$set(this.obj, "b", 4);

            // this.arr[0] = 9;
            // this.$set(this.arr, 0, 9);

            // this.arr.length = 1;
            this.arr.splice(1);
          },
        },
      });
    </script>
  </body>
</html>
